package crons;

import javax.servlet.ServletException;
import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;

import entities.Webmail;

import models.WebmailModel;

import systems.MailSystem;

public class WebmailRunning extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException {
		
		if (MailSystem.getStatus() == 1) {
			WebmailModel webmailModel = WebmailModel.getInstance();
			Webmail webmail = webmailModel.getWatting();
			
			if (webmail != null) {
				MailSystem.reset();
				MailSystem.setId(webmail.getId());
				MailSystem.setStatus(0);
			}
		} else {
			response.getWriter().println("Nothing");
		}
	}
}
